package com.alan.designMode.proxy;

import com.alan.designMode.dynamicproxy.Subject;

/**
 * 代理类
 * Created by Alan on 17-8-29
 */
public class Proxy implements Subject {

    //要代理哪个实现类
    private Subject subject = null;

    //默认代理类
    public Proxy() {
        this.subject = new Proxy();
    }

    //通过构造函数传递代理者
    public Proxy(Subject subject) {
        this.subject = subject;
    }

    //实现接口中定义的方法
    @Override
    public void doSomething(String msg) {
        this.subject.doSomething(msg);
    }

    //预处理
    private void before(){
        //do something
    }

    //善后处理
    private void after(){
        //do something
    }

}
